package com.example.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author xbb
 */
@SpringBootApplication
public class XbbUtilsApplication {

    private static final Logger LOGGER = LoggerFactory.getLogger(XbbUtilsApplication.class);

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(XbbUtilsApplication.class, args);
        LOGGER.info("启动成功\n");
        ConfigurableEnvironment env = applicationContext.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        LOGGER.info(System.lineSeparator()
                + "----------------------------------------------------------" + System.lineSeparator() +
                "\tApplication  is running! Access URLs:" + System.lineSeparator() +
                "\tLocal: \t\thttp://localhost:" + port + path + System.lineSeparator() +
                "\tExternal: \thttp://" + ip + ":" + port + path + System.lineSeparator() +
                "----------------------------------------------------------");

    }

}
